#coding=utf-8
import memcache,time
import DBConnection
mc = memcache.Client(['192.168.1.14:11211','192.168.1.26:11211'],debug=1);

mc.debuglog("start")


import codecs
##import cx_Oracle
##formatString = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)" +"(HOST=%s)(PORT=%d)))(CONNECT_DATA=(SID=%s)))"
##args = ("192.168.1.20", 1521, "inst20")
##result = cx_Oracle.makedsn(*args)

##ora = cx_Oracle.connect("unsins","password",result)
ora = DBConnection.DBConnection().getConnection();
curs = ora.cursor()
curs.execute('select * from t_person')

row = curs.fetchone()
##mc.set("odpsoft",curs.fetchall());
while row:
    companyname = unicode(row[2],"gbk");
    mc.set("%d"%row[0],companyname.encode("utf-8"),min_compress_len=123);



    print row[0],row[2]
    row = curs.fetchone()

##curs = ora.cursor()
##curs.execute('select * from t_company')
##row = curs.fetchone()
##while row:
##    companyname = mc.get("%d"%row[0]);
##    print companyname[4]
##    row = curs.fetchone()



##odpcurs = mc.get("odpsoft");
##for odprow in odpcurs:
##    print odprow[4]
print mc.get("115");
print mc.get("odpsoftrong");
mc.set("1234567","敏敏");
llist =  mc.buckets()
for li in llist:
    print li

mc.disconnect_all();
print mc.get_stats();


curs.close()
ora.close()
